<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    * {
      padding: 0;
      margin: 0;
    }
    body {
      height: 3000px;
    }
    .header {
      /* 粘性定位 */
      position: sticky;
      top: 4px;
      /* 初始位置 */
      margin: 100px auto;
      width: 1200px;
      height: 50px;
      background-color: #eee;
    }
    .header h3 {
      line-height: 50px;
      margin-left: 30px;
    }
  </style>
  <body>
    <div class="header">
      <h3>我是导航</h3>
    </div>
  </body>
</html>
